# coding=utf-8
"""
author: jamon
"""
import os

import pygame

from client.config import ClientConfig
from client.model.entity_base import EntityBase
from package.static.const import TypeIdConst, Faction
from package.posi import Position


class Tree(EntityBase):
    # 树

    def __init__(self, type_id: TypeIdConst, faction: Faction, position: Position, **kwargs):
        super(Tree, self).__init__(type_id, postion=position, **kwargs)
        root_dir = ClientConfig().root_dir
        self.image_path = os.path.join(root_dir, self.static_info.image[faction][-1])
        self.image: pygame.Surface = pygame.Surface((24, 24))
        for i in range(2):
            for j in range(2):
                self.image.blit(pygame.image.load(self.image_path).convert_alpha(), (12 * i, 12 * j))
        self.rect = self.image.get_rect()
        self.rect.left, self.rect.top = position.x, position.y
